# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=doxygen

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.8.6
pkgrel=1
pkgdesc="A documentation system for C++, C, Java, IDL and PHP (mingw-w64)"
arch=('any')
url="http://www.doxygen.org/"
options=('strip' 'staticlibs')
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-recode")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" 'flex' "${MINGW_PACKAGE_PREFIX}-ghostscript" "${MINGW_PACKAGE_PREFIX}-python2")
source=("http://ftp.stack.nl/pub/users/dimitri/${_realname}-${pkgver}.src.tar.gz"
    'doxygen-configure-python2.patch'
    'force-win32.patch'
    'tmake-unquote.patch'
    'fix-casts.patch')
md5sums=('9385dc52f0627875f8fa758e754ec674'
         'a16ef06cd207292eda73801ea3835f1e'
         'cf50ccbc57c31cd7f113a5644e6c9dbc'
         'eb90b49191ae8964a1887d2155ff8c50'
         '0353522adae552b0a6cf3899f5cb8b3b')
noextract=(${_realname}-${pkgver}.src.tar.gz)

prepare() {
  cd ${srcdir}
  [[ -d $srcdir/${_realname}-${pkgver} ]] || tar -xzvf ${startdir}/${_realname}-${pkgver}.src.tar.gz -C $srcdir
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}/doxygen-configure-python2.patch"
  patch -p1 -i "${srcdir}/force-win32.patch"
  patch -p1 -i "${srcdir}/tmake-unquote.patch"
  patch -p1 -i "${srcdir}/fix-casts.patch"
}

build() {
  export QTDIR=${MINGW_PREFIX}
  cd ${srcdir}/${_realname}-${pkgver}
  ./configure \
    --prefix ${MINGW_PREFIX} \
    --with-sqlite3 \
    --sqlite3-path ${MINGW_PREFIX} \
    --shared
  make
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}

  #make DESTDIR="${pkgdir}" install
  make INSTALL="${pkgdir}${MINGW_PREFIX}" MAN1DIR=share/man/man1 install
  #rm -r "${pkgdir}${MINGW_PREFIX}"/share/man
}
